'''
KML Enumerated Classes
Created on Sep 28, 2010

@author: morgan
'''

from base import Boolean, Mode

__all__ = ['altitudeMode', 'displayMode', 'extrude', 
           'tessellate', 'colorMode', 'refreshMode', 'viewRefreshMode']

class altitudeMode(Mode):
    """
    Specifies how altitude components in the <coordinates> element are 
    interpreted. Possible values are:
    
    - I{clampToGround} - (default) Indicates to ignore an altitude specification 
      (for example, in the <coordinates> tag).
      
    - I{relativeToGround} - Sets the altitude of the element relative to the
      actual ground elevation of a particular location. For example, if the 
      ground elevation of a location is exactly at sea level and the altitude 
      for a point is set to 9 meters, then the elevation for the icon of a point
      placemark elevation is 9 meters with this mode. However, if the same 
      coordinate is set over a location where the ground elevation is 10 meters
      above sea level, then the elevation of the coordinate is 19 meters. A 
      typical use of this mode is for placing telephone poles or a ski lift.
      
    - I{absolute} - Sets the altitude of the coordinate relative to sea level, 
      regardless of the actual elevation of the terrain beneath the element. 
      For example, if you set the altitude of a coordinate to 10 meters with an 
      absolute altitude mode, the icon of a point placemark will appear to be at
      ground level if the terrain beneath is also 10 meters above sea level. If
      the terrain is 3 meters above sea level, the placemark will appear 
      elevated above the terrain by 7 meters. A typical use of this mode is for 
      aircraft placement
      
    - I{relativeToSeaFloor} - Like absolute, but sets the altitude of the 
      coordinate relative to the sea floor.
    
    - I{clampToSeaFloor} - Like clampToGround, but clamps to the sea floor.
    
    Example usage::
    
        mode = kml.altitudeMode() 
        point = kml.Point()
        point.AltitudeMode = mode.clampToGround
    """
    def __init__(self, mode="absolute"):
        self._validModes = ["clampToGround",
                            "relativeToGround",
                            "absolute",
                            "relativeToSeaFloor",
                            "clampToSeaFloor"]
        self.__defaultMode__ = "absolute"
        self.__tagName__ = "altitudeMode"
        Mode.__init__(self, mode)
    
    clampToGround = "clampToGround"
    relativeToGround = "relativeToGround"
    absolute = "absolute"
    relativeToSeaFloor = "relativeToSeaFloor"
    clampToSeaFloor = "clampToSeaFloor"
    default = absolute
   
    
class displayMode(Mode):
    """
    If B{displayMode} is I{default}, Google Earth uses the information supplied 
    in B{text} to create a balloon . If B{displayMode} is I{hide}, Google Earth 
    does not display the balloon. In Google Earth, clicking the List View icon 
    for a B{Placemark} whose balloon's B{displayMode} is I{hide} causes Google 
    Earth to fly to the Placemark.
    """
    def __init__(self, mode="default"):
        self.__tagName__ = "displayMode"
        self.__defaultMode__ = "default"
        self._validModes = ["default", "hide"]
        Mode.__init__(self, mode)
    
    default = "default"
    hide = "hide"
    

class extrude(Boolean):
    def __init__(self, value=False):
        self.__tagName__ = "extrude"
        Boolean.__init__(self, value)
        
class tessellate(Boolean):
    def __init__(self, value=False):
        self.__tagName__ = "tessellate"
        Boolean.__init__(self, value)
                
class colorMode(Mode):
    """
    colorMode field for a ColorStyle class descendant.
    
    Values for /colorMode/ are normal (no effect) and random. A value of random 
    applies a random linear scale to the base <color> as follows. 
    
    * To achieve a truly random selection of colors, specify a base <color> of 
      white (00ffffff).
    
    * If you specify a single color component (for example, 
      a value of ff0000ff for red), random color values for that one component 
      (red) will be selected. In this case, the values would range from 00 
      (black) to ff (full red).

    * If you specify values for two or for all three color components, a random 
      linear scale is applied to each color component, with results ranging from
      black to the maximum values specified for each component. The opacity of 
      a color comes from the alpha component of <color> and is never randomized.

    """
    def __init__(self, mode="normal"):
        self.__tagName__ = "colorMode"
        self.__defaultMode__ = "normal"
        self._validModes = ["normal", "random"]
        Mode.__init__(self, mode)

    normal = "normal"
    random = "random"
    default = normal
    
class refreshMode(Mode):
    def __init__(self, mode = "onChange"):
        self.__tagName__ = "refreshMode"
        self.__defaultMode__ = "onChange"
        self._validModes = ["onChange", "onInterval", "onExpire"]
        Mode.__init__(self, mode)
    
    onChange = "onChange"
    onExpire = "onExpire"
    onInterval = "onInterval"
    default = onChange

class refreshVisibility(Boolean):
    def __init__(self, value=False):
        self.__tagName__ = "refreshVisibility"
        Boolean.__init__(self, value)
    
class flyToView(Boolean):
    def __init__(self, value=False):
        self.__tagName__ = "flyToView"
        Boolean.__init__(self, value)

class viewRefreshMode(Mode):
    def __init__(self, mode = "never"):
        self.__tagName__ = "viewRefreshMode"
        self.__defaultMode__ = "never"
        self._validModes = ["never", "onStop", "onRequest", "onRegion"]
        Mode.__init__(self, mode)
        
    never = "never"
    onStop = "onStop"
    onRequest = "onRequest"
    onRegion = "onRegion"
    default = never
